"""
send_keys(Keys.BACK_SPACE) #删除键（BackSpace）
send_keys(Keys.SPACE) #空格键(Space)
send_keys(Keys.TAB) #制表键(Tab)
send_keys(Keys.ESCAPE) #回退键（Esc）
send_keys(Keys.ENTER) #回车键（Enter）
send_keys(Keys.CONTROL,‘a’) #全选（Ctrl+A）
send_keys(Keys.CONTROL,‘c’) #复制（Ctrl+C）
send_keys(Keys.CONTROL,‘x’) #剪切（Ctrl+X）
send_keys(Keys.CONTROL,‘v’) #粘贴（Ctrl+V）
send_keys(Keys.F1) #键盘 F1
...
send_keys(Keys.F12) #键盘 F12


from selenium.webdriver.common.keys import Keys
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

driver = webdriver.Chrome()
driver.maximize_window()
driver.get('https://www.baidu.com/')

driver.find_element(By.ID,'kw').send_keys("柠檬班")

# 回车
# driver.find_element(By.ID,"kw").send_keys(Keys.ENTER)
# 回删键
driver.find_element(By.ID,"kw").send_keys(Keys.BACK_SPACE)
sleep(2)
driver.find_element(By.ID,"kw").send_keys(Keys.BACK_SPACE)
sleep(1)
# 组合键 - 全选
driver.find_element(By.ID,"kw").send_keys(Keys.CONTROL,"a")
sleep(2)
# 组合键 - 复制
driver.find_element(By.ID,"kw").send_keys(Keys.CONTROL,"c")
driver.find_element(By.ID,"kw").clear() # 文本清空
sleep(2)
# 组合键 - 粘贴
driver.find_element(By.ID,"kw").send_keys(Keys.CONTROL,"v")
sleep(2)
driver.find_element(By.ID,"kw").send_keys(Keys.CONTROL,"v")
sleep(2)
driver.quit()
"""

# 练习


from selenium.webdriver.common.keys import Keys
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep

driver = webdriver.Chrome()
driver.maximize_window()
driver.get('https://www.baidu.com/')

driver.find_element(By.ID,'kw').send_keys("柠檬班")
sleep(2)
driver.find_element(By.ID,'kw').send_keys(Keys.CONTROL,"a")
sleep(2)
driver.find_element(By.ID,'kw').send_keys(Keys.CONTROL,"x")
sleep(2)
driver.find_element(By.ID,'kw').send_keys(Keys.CONTROL,"v")
sleep(2)
# 总结
# 鼠标操作很少使用。